import Vue from 'vue';

Vue.mixin({
    data() {
        return {
            overFormItem: {},
            overRoleDataList: []
        };
    },
    methods: {
        $loginOut() {
            this.$Modal.confirm({
                title: '提示',
                content: '网络错误或服务器崩溃！！！',
                okText: '退出系统',
                cancelText: '取消',
                onOk: () => {
                    this.$auth.logout({
                        success: function () {
                        },
                        error: function () {
                        }
                    });
                },
                onCancel: () => {
                    return false;
                }
            });
        },
        $error(error, millisecond = 1) {
            millisecond = millisecond <= 3 ? 4 : 5;
            return this.$Notice.error({
                title: '提示',
                desc: error,
                duration: millisecond
            });
        },
        $success(msg, millisecond = 1) {
            millisecond = millisecond <= 3 ? 4 : 5;
            return this.$Notice.success({
                title: '提示',
                desc: msg,
                duration: millisecond
            });
        },
        $warn(msg, millisecond = 1) {
            millisecond = millisecond <= 3 ? 4 : 5;
            return this.$Notice.warning({
                title: '提示',
                desc: msg,
                duration: millisecond
            });
        },
        $handleFormatter(data, list, keys, name) {
            if (typeof data != 'undefined' && data !== null && data !== '') {
                for (let i = 0; i < list.length; i++) {
                if (data.toString() == list[i][keys]) {
                    return list[i][name];
                }
                }
            }
        },
        $formatterDict(val, list) {
            if (typeof val !== 'undefined' && val !== null && val !== '') {
                for (let i = 0; i < list.length; i++) {
                if (list[i].dictValue === val.toString()) {
                    return list[i].dictName;
                }
                }
            }
        },
    },
    mounted() {
    }
});
